package com.example.scala.chapter3

/**
 *
 * Description:
 *
 * Create by lucienoz on 2021/10/14.
 * Copyright © 2021 lucienoz. All rights reserved.
 */
object chapter04 {
  def main(args : Array[String]) : Unit = {
    val foo : String = "foo"
    val bar : String = new String("foo")

    println ( foo == bar ) //AnyVal == 比较值，true
    println ( foo.==(bar) ) //AnyVal == 实际调用.==()，true
    println ( foo.equals(bar) )//java String类 equals 比较值，true
    println(foo eq bar) //比较对象存储地址 ，false

    val user01 : User = new User ( "user01" )
    val user02 : User = new User ( "user01" )

    println ( user01 == user02 )//true, 重写了equals方法比较name的值
    println ( user01 eq user02 ) //false ,比较对象的地址


  }

}
